package Class_04_07;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Random;

class Student
{
    private String ID;
    private String name;
    private String sex;
    private int age;

    private double mid_exam;
    private double end_exam;

    public void PrintInfo()
    {

    }

    public Student() {
    }

    public Student(String ID, String name, String sex, int age, double mid_exam, double end_exam) {
        this.ID = ID;
        this.name = name;
        this.sex = sex;
        this.age = age;
        this.mid_exam = mid_exam;
        this.end_exam = end_exam;
    }

    public String getID() {
        return ID;
    }

    public void setID(String ID) {
        this.ID = ID;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getSex() {
        return sex;
    }

    public void setSex(String sex) {
        this.sex = sex;
    }

    public int getAge() {
        return age;
    }

    public void setAge(int age) {
        this.age = age;
    }

    public double getMid_exam() {
        return mid_exam;
    }

    public void setMid_exam(double mid_exam) {
        this.mid_exam = mid_exam;
    }

    public double getEnd_exam() {
        return end_exam;
    }

    public void setEnd_exam(double end_exam) {
        this.end_exam = end_exam;
    }
}

class EnglishStudent extends Student
{
    private double lecture;

    public EnglishStudent(String ID, String name, String sex, int age, double mid_exam, double end_exam, double lecture) {
        super(ID, name, sex, age,  mid_exam, end_exam);
        this.lecture = lecture;
    }

    public void PrintInfo()
    {
        System.out.println("学号：" + getID() + " 姓名：" + getName() + " 性别：" + getSex() + " 年龄" + getAge() + " 综合成绩：" + ((lecture * 0.5) + getMid_exam() * 0.25 + getEnd_exam() * 0.25));
    }
}

class ComputerStudent extends Student
{
    private double AbiOperation;
    private double EnglishWrite;

    public ComputerStudent() {
    }

    public ComputerStudent(String ID, String name, String sex, int age, double mid_exam, double end_exam, double abiOperation, double englishWrite) {
        super(ID, name, sex, age, mid_exam, end_exam);
        AbiOperation = abiOperation;
        EnglishWrite = englishWrite;
    }

    public void PrintInfo()
    {
        System.out.println("学号：" + getID() + " 姓名：" + getName() + " 性别：" + getSex() + " 年龄" + getAge() + " 综合成绩：" + ((AbiOperation * 0.4) + (EnglishWrite * 0.2) + (getMid_exam() * 0.2) + (getEnd_exam() * 0.2)));
        return;
    }
}

class LiteratureStudent extends Student
{
    private double lecture;
    private double works;

    public LiteratureStudent() {
    }

    public LiteratureStudent(String ID, String name, String sex, int age, double mid_exam, double end_exam, double lecture, double works) {
        super(ID, name, sex, age, mid_exam, end_exam);
        this.lecture = lecture;
        this.works = works;
    }

    public void PrintInfo()
    {
        System.out.println("学号：" + getID() + " 姓名：" + getName() + " 性别：" + getSex() + " 年龄" + getAge() + " 综合成绩：" + ((lecture * 0.35) + (works * 0.35) + (getMid_exam() * 0.15) + (getEnd_exam() * 0.15)));
        return;
    }
}

public class Main3 {
    public static void main(String[] args) {
        Random r = new Random();
        String sex;
        int index = 0;
        String[] names = {"Jack","Mary","Black","Max","July"};
        ArrayList<String> namesList = new ArrayList<>(Arrays.asList(names));
        Student[] stu = new Student[5];

        for (int i = 0; i < 5; i++)
        {
            index = r.nextInt(namesList.size());
            if(r.nextInt(2) == 0)
            {
                sex = "女";
            }
            else
            {
                sex = "男";
            }
            int depart = r.nextInt(3);//0-英语 / 1-计算机 / 2-文学
            switch (depart)
            {
                case 0:
                    stu[i] = new EnglishStudent("2023080645" + r.nextInt(99), namesList.get(index), sex, 18+r.nextInt(6), r.nextInt(101), r.nextInt(101), r.nextInt(101));
                    break;
                case 1:
                    stu[i] = new ComputerStudent("2023080645" + r.nextInt(99), namesList.get(index), sex, 18+r.nextInt(6), r.nextInt(101), r.nextInt(101), r.nextInt(101),r.nextInt(101));
                    break;
                case 2:
                    stu[i] = new LiteratureStudent("2023080645" + r.nextInt(99), namesList.get(index), sex, 18+r.nextInt(6), r.nextInt(101), r.nextInt(101), r.nextInt(101),r.nextInt(101));
                    break;
            }
            namesList.remove(index);
        }
        for (int j = 0; j < stu.length; j++) {
            stu[j].PrintInfo();
        }
    }
}
